<?php
# note that this function promises that to fetch a class
# by its name and prevent including a class more than once
using("Libs_Catalog");
using("Db_Common_ResultSet");


# note that this is a regular require and makes no promises
# about whether the library will be included more than once
get(Libs_Catalog::fetch("adodb/adodb.inc"));
get(Libs_Catalog::fetch("adodb/adodb-exceptions.inc"));

/**
 * Implementation of the common recordset interface
 *
 * @package junction.db.adodb
 * @author Alexander Schearer <aas11@duke.edu>
 */
class Db_Adodb_ResultSet implements Db_Common_ResultSet {
	
	/**
	 * Adodb RecordSet
	 *
	 * @var ADORecordSet
	 */
	private $_resultset;
	
	/**
	 * Query string which produced this object
	 *
	 * @var String a SQL query
	 */
	private $_query;
	
	/**
	 * Create a new record set
	 *
	 * @param ADORecordSet $results
	 * @param String $query
	 */
	public function __construct(ADORecordSet & $results, $query) {
		$this->_resultset = $results;
		$this->_query = $query;
	}
	
	/**
	 * Retrieve the query which produced this object
	 * 
	 * @see Db_Common_ResultSet::getQuery()
	 *
	 * @return String the query which produced this resultset
	 */
	public function getQuery() {
		return $this->_query;
	}
	
	/**
	 * Returns an iterator which traverses the resultset
	 *
	 * @return Iterator
	 */
	public function getIterator() {
		return $this->_resultset->getIterator();
	}
}
?>